﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
    Layout = null;
}
@* 仓库新增页面 *@
<link href="~/lib/layui/css/layui.css" rel="stylesheet" />
<script src="~/lib/layui/layui.js"></script>
<script src="~/js/js.cookie.js"></script>
<script src="~/js/moment.js"></script>
<script src="~/lib/jquery/dist/jquery.js"></script>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>Demo</title>
    <!-- 请勿在项目正式环境中引用该 layui.css 地址 -->
    <link href="//unpkg.com/layui@2.9.20/dist/css/layui.css" rel="stylesheet" />
</head>
<body class="layui-padding-3">
    <h3>仓库管理/仓库列表/添加</h3>
    <form class="layui-form" action="">
        <div class="layui-form-item">
            <label class="layui-form-label">仓库编码：</label>
            <div class="layui-input-block">
                <input type="text"
                       name="warehousNumBer"
                       lay-verify="required"
                       id="warehousNumBer"
                       autocomplete="off"
                       class="layui-input" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">仓库名称：</label>
            <div class="layui-input-block">
                <input type="text"
                       name="warehouseName"
                       lay-verify="required"
                       id="warehouseName"
                       autocomplete="off"
                       class="layui-input" />
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">仓库地址：</label>
            <div class="layui-input-block">
                <input type="text"
                       name="warehouseAddr"
                       lay-verify="required"
                       id="warehouseAddr"
                       autocomplete="off"
                       class="layui-input" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">备注：</label>
            <div class="layui-input-block">
                <textarea class="layui-textarea" id="warehouseRemark"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">状态：</label>
            <div class="layui-input-block">
                <select id="warehouseState" lay-filter="aihao">
                    <option name="warehouseState" value=true >有效</option>
                    <option name="warehouseState" value=false >无效</option>
                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="button" class="layui-btn" lay-submit lay-filter="demo1" lay-on="alert" onclick="WareHouseAdd()">
                    确定
                </button>

             </div>
        </div>
    </form>

    <!-- 请勿在项目正式环境中引用该 layui.js 地址 -->
    <script src="//unpkg.com/layui@2.9.20/dist/layui.js"></script>
    <script>
        layui.use( function () {
            var form = layui.form;
            var layer = layui.layer;
            var laydate = layui.laydate;
            var util = layui.util;
        });

    </script>
</body>
</html>
<script>
    layui.use(function () {
        var form = layui.form;
        var layer = layui.layer;
        var laydate = layui.laydate;
        var util = layui.util;
    });
 
    //仓库新增
    function WareHouseAdd() {
        var data = {
            warehousNumBer: $("#warehousNumBer").val(),
            warehouseName: $("#warehouseName").val(),
            warehouseAddr: $("#warehouseAddr").val(),
            warehouseRemark: $("#warehouseRemark").val(),
            warehouseState: $("[name=warehouseState]:checked").val()=='true',
        };
        console.log(JSON.stringify( data ));
        $.ajax({
            url: '@ViewBag.RBACWrite' + "/api/Warehouse/WareHouseAdd",
            type: 'post',
            data: JSON.stringify(data),
            dataType: "json",
            contentType: "application/json",
            success: res => {
                if (res.code == 1) {
                    layer.alert(res.msg);
                }
                else {
                    layer.alert(res.msg);
                }
            }
        })

    }
</script>



